'use strict';

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      // 任务1：匹配所有js
      release: {
        options: {
          banner: '/*   \n *  Project: <%= pkg.name %> \n *  Author: xcold \n *  Website:http://lxstart.net \n *  <%= pkg.name %> Latestly modified： <%= grunt.template.today("yyyy-mm-dd") %> \n */\n ',
          footer: '\n/*! <%= pkg.name %> Latestly modified： <%= grunt.template.today("yyyy-mm-dd") %> */'
        },
        // 源文件压缩不合并
        files: [{
          expand: true,
          src: ['src/**/*.js'], //所有js文件
          dest: 'dist/' //输出到此目录
        }]
      },
      // 任务2：还原特定文件
      build: {
        // 源文件压缩不合并
        files: [{
          expand: true,
          cwd: 'src/js', // src目录下
          src: ['mobiscroll/', 'jquery.min.js'],
          dest: 'dist/src/js' //输出到此目录
        }]
      }
    },
    cssmin: {
      release: {
        options: {
          banner: '/*   \n *  Project: <%= pkg.name %> \n *  Author: xcold \n *  Website:http://lxstart.net \n *  Time: <%= grunt.template.today("dd-mm-yyyy") %> \n */\n '
        },
        files: [{
          expand: true,
          src: ['src/css/*.css'],
          dest: 'dest/'
        }]
      }
    }
  });

  // 加载任务
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-css');

  // 注册插件
  grunt.registerTask('default', ['cssmin:release',, 'uglify:release', 'uglify:build']);
}
